home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / voyager7.exe / ASC.TXT < prev    next >
Text File  |  1991-02-23  |  5KB  |  134 lines

  1.  
  2.                       ASCII Encoding HP 48SX Objects
  3.  
  4. Sending an HP 48SX object via electronic mail can be difficult if the
  5. object does not have an ASCII form, such as is the case for library
  6. objects.  There are various encoding schemes available on different
  7. computer systems, but these require that the sender and receiver have
  8. similar computers, or at least compatible encode/decode schemes.  The
  9. programs listed below perform the encoding and decoding on the HP 48SX itself,
  10. which has the advantage of being completely independent of any computer.
  11.  
  12. The programs are nominally called \->ASC and ASC\->.  The former takes an
  13. object from the stack and converts it to a string, in which each nibble of the
  14. object and its checksum is converted to a character 0-9 or A-F.  (The object
  15. must be in RAM, otherwise a "ROM Object" error is returned.)  For sake of easy
  16. inclusion in email letters, the string is broken up by linefeed characters
  17. after every 64 characters.
  18.  
  19. ASC\-> is the inverse of \->ASC: it takes a string created by \->ASC and
  20. converts it back into an object.  When you transmit the encoded strings,
  21. be sure not to change the string; ASC\-> uses the checksum encoded in the
  22. string to verify that the decoding is correct.  An "Invalid String" error
  23. is returned if the result object does not match the original object
  24. encoded by \->ASC.  When you upload a string to your computer, use HP 48
  25. translate mode 3 so that the HP 48 will convert any CR/LF's back to LF's
  26. when the string is later downloaded.
  27.  
  28. Two versions of ASC\-> are included here.  The first (P1) is in HP 48 user
  29. language, using SYSEVALs to execute system objects.  P2 is a
  30. string that the setup program uses P1 to decode into an executable
  31. ASC\->--then P1 is discarded.  The second version is more
  32. compact than the first, and also uneditable and therefore safer (but it can't
  33. be transmitted in ASCII form, which helps to make the point of this exercise).
  34.  
  35. Here are the programs, contained in a directory:
  36.  
  37. (start)
  38. %%HP: T(3)A(D)F(.);
  39. DIR
  40. P1              @ ASC\-> Version 1.
  41. \<<
  42.   IF DUP TYPE 2 \=/
  43.   THEN "Not A String" DOERR
  44.   END RCWS \-> ws
  45.   \<< 16 STWS
  46.     #0 NEWOB SWAP DUP SIZE
  47.     IF DUP 4 <
  48.     THEN DROP SWAP DROP "Invalid String" DOERR
  49.     END 
  50.     DUP 65 / IP - 4 - # 18CEAh SYSEVAL 
  51.     "" OVER # 61C1Ch SYSEVAL
  52.     SWAP # 6641F8000AF02DCCh
  53.     # 130480679BF8CC0h # 518Ah SYSEVAL
  54.     # 19610313418D7EA4h # 518Ah SYSEVAL
  55.     # 7134147114103123h # 518Ah SYSEVAL
  56.     # 5F6A971131607414h # 518Ah SYSEVAL
  57.     # 12EA1717EA3F130Ch # 518Ah SYSEVAL
  58.     # 280826B3012808F4h # 518Ah SYSEVAL
  59.     # 6B7028080BEE9091h # 518Ah SYSEVAL
  60.     # BE5DC1710610C512h # 518Ah SYSEVAL
  61.     # 705D00003431A078h # 518Ah SYSEVAL
  62.     # 3D8FA26058961431h # 518Ah SYSEVAL
  63.     # 312B0514h # 518Ah SYSEVAL 
  64.     # 18F23h SYSEVAL 
  65.     DUP BYTES DROP 4 ROLL
  66.     IF ==
  67.     THEN SWAP DROP
  68.     ELSE DROP "Invalid String" DOERR
  69.     END ws STWS
  70.   \>>
  71. \>>
  72.  
  73. P2    @ ASC\->  Version 2.  To be converted by ASC\-> version 1.
  74.  
  75. "D9D20D29512BF81D0040D9D20E4A209000000007566074726636508813011920
  76. 140007FE30B9F060ED3071040CA1304EC3039916D9D2085230B9F06C2A201200
  77. 094E66716C696460235472796E676933A1B21300ED30FD5502C230C1C1632230
  78. CCD20FA0008F14660CC8FB97608403104AE7D814313016913213014117414317
  79. 414706131179A6F5C031F3AE7171AE214F8082103B6280821909EEB0808207B6
  80. 215C0160171CD5EB870A13430000D50713416985062AF8D341508813044950B9
  81. F06BBF06EFC36B9F0644230C2A201200094E66716C696460235472796E676933
  82. A1B2130B21300373"
  83.  
  84.  
  85. P3    @\->ASC.     To be converted by ASC\->.
  86. "D9D20D2951881304495032230FD5502C230A752688130ADB467FE30322306AC3
  87. 0CB916E0E30CBD30F6E30C1C1632230CCD20DC0008F14660CC8FB97608403104
  88. AE7D8143130169174147061741431311534AC6B4415141534946908D9B026155
  89. 4A6F53131F3AE731A014C161AE215F08082103A6280821939EEC08082170A621
  90. 4C161170CD56B870A18503430000D5071351796A9F8D2D02639916D9D2085230
  91. C2A209100025F4D402F426A6563647933A1B2130A2116B213033C0"
  92.  
  93. SETUP    @Automatic setup program
  94. \<< P2 P1 'ASC\->' STO
  95.     P3 ASC\-> '\->ASC' STO
  96.     { P1 P2 P3 SETUP } PURGE
  97. \>>
  98.  
  99. END
  100. (end)
  101.  
  102.  
  103. Installation instructions:
  104.  
  105. 1.  Edit the above text between (start) and (end) into a text file named
  106. CONV (for example).  
  107. Be sure that you leave the strings exactly as entered above,
  108. with no extra spaces or other invisible characters at the beginnings or
  109. ends of the lines.
  110. 2.  Set the HP 48SX into ASCII transfer mode.
  111. 3.  Using Kermit, download CONV text file to the 48, verify its checksum
  112. (6C8Ah).
  113. 4.  Execute CONV to make it the current directory.
  114. 5.  Execute SETUP.
  115. 6.  The directory CONV now contains ASC\-> and \->ASC, ready to use.
  116.  
  117. To archive the decoded versions of ASC\-> and \->ASC back on your computer,
  118. be sure to set the HP 48SX in binary transfer mode before uploading.
  119.  
  120. Disclaimers:
  121.  
  122. * Use the programs at your own risk.  Any time you delve into the SYSEVAL
  123. world, there are increased dangers.  Archive your 48 memory before 
  124. experimenting with these programs!  Also, verify the checksums of objects
  125. defined above to make sure they have been downloaded correctly, before
  126. executing ASC\->.
  127.  
  128. * I will not answer questions about how the programs work.  This is not
  129. because of any great secrecy, but rather because it's hard to give
  130. any answer that doesn't lead to more questions, and more, and more...
  131.  
  132. * 48 hackers are welcome to mine any nuggets they can from the programs,
  133. and from the fact that \->ASC is a convenient way to decompile an object.
  134.